package com.xiaotao.test01.controller;

import cn.hutool.core.lang.UUID;
import cn.hutool.core.lang.id.NanoId;
import com.xiaotao.test01.service.WebSocket;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author asus
 */
@RestController
@RequestMapping("socket")
@RequiredArgsConstructor
public class WebSocketController {
    private final WebSocket webSocket;

    @RequestMapping("getServerStatus")
    public String getServerStatus(){
        boolean serverStatus = webSocket.getServerStatus();
        if (!serverStatus) {
            throw new RuntimeException("服务端不在线，请联系管理员");
        }
        return UUID.randomUUID().toString();
    }

    @RequestMapping("askServer")
    public Boolean askServer(){

        return webSocket.getServerStatus();
    }
}
